﻿using System;
using System.Collections;
using System.Data;
using CE.Database;

/// <summary>
/// Summary description for SubPageUserAccessDB
/// </summary>
/// 
namespace CE.UserAccess
{
    public class SubPageUserAccessDB
    {
        public SubPageUserAccessDB()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public Int64 Insert(SubPageUserAccess subpageuseraccess)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "sprocProviderUserAccessSubPagesInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter

            _sPara.Add("@RefCEUserId", subpageuseraccess.RefCEUserId);
            _sPara.Add("@ProviderCompanyId", subpageuseraccess.ProviderCompanyId);
            _sPara.Add("@MainPageId", subpageuseraccess.MainPageId);
            _sPara.Add("@SubPageId", subpageuseraccess.SubPageId);
            _sPara.Add("@AccessLevel", subpageuseraccess.AccessLevel);
            _sPara.Add("@Status", subpageuseraccess.Status);

            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public DataTable GetSubPageAccess(Int64 ProviderCompanyId, Int64 MainPageId, Int64 SubPageId, Int64 RefCEUserId)
        {
            MyDatabase _db = new MyDatabase();
            DataTable _dtResult = new DataTable();
            string _spName = "sprocProviderUserAccessSubPagesSelectItemListByUser";
            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@ProviderCompanyId", ProviderCompanyId);
            _sPara.Add("@MainPageId", MainPageId);
            _sPara.Add("@SubPageId", MainPageId);
            _sPara.Add("@RefCEUserId", RefCEUserId);
            #endregion

            _dtResult = _db.GetDataTableBySP(_spName, _sPara);

            return _dtResult;
        }

    }
}